<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>个人中心</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link th:href="@{/layui/css/layui.css}" rel="stylesheet">
</head>
<body class="background-info">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">个人中心</div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <!-- 移动端显示 -->
            <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                <i class="layui-icon layui-icon-spread-left"></i>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-sm-inline-block">
                <!--顶部头像-->
                <a href="javascript:;">
                    <img class="layui-nav-img userAvatar"
                         height="35"
                         th:src="@{${session.user.imgPath}(t=${T(java.lang.System).currentTimeMillis()})}"
                         width="35"
                         alt="头像"
                         onerror="this.src='/images/default.jpeg'">
                    <cite class="adminName" th:text="${session.user.username}"></cite>
                </a>
                <dl class="layui-nav-child">
                    <dd><a th:href="@{/}">返回首页</a></dd>
                    <dd><a class="signOut" th:href="@{/logout}"><i class="seraph icon-tuichu"></i><cite>退出</cite></a></dd>
                </dl>
            </li>
        </ul>
    </div>
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- ⚠️左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item"><a th:href="@{/user/toUserInfo}" id="userInfoLink">个人信息</a></li>
                <li class="layui-nav-item"><a th:href="@{/user/toChangePassword}" id="changePasswordLink">修改密码</a></li>
            </ul>
        </div>
    </div>
    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div id="contentArea" style="padding: 15px;">
            <blockquote class="layui-elem-quote layui-text">
                Layui 框体布局 RKSJGL个人中心的内容主体区域
            </blockquote>
        </div>
    </div>

    <!-- 预加载图片（隐藏） -->
    <img id="wechatImg" th:src="@{/images/donation/wechat.jpg}" style="display: none;">
    <img id="alipayImg" th:src="@{/images/donation/alipay.png}" style="display: none;">

    <!--底部固定区域-->
    <div class="layui-footer footer">
        <p style="text-align: center"><span>copyright @2025 Climb_LFZ</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a class="layui-btn-radius layui-btn layui-btn-danger layui-btn-sm"
                                                    onclick="donation()">捐赠作者</a></p>
    </div>
</div>

<script th:src="@{/layui/layui.js}"></script>
<script>
    //JS
    layui.use(['element', 'layer', 'util', 'jquery'], function(){
        var element = layui.element;
        var layer = layui.layer;
        var util = layui.util;
        var $ = layui.$;

        // ⚠️给左侧菜单添加点击事件
        $('#userInfoLink').click(function(e) {
            e.preventDefault();
            loadPageContent('/user/toUserInfo');
        });

        $('#changePasswordLink').click(function(e) {
            e.preventDefault();
            loadPageContent('/user/toChangePassword');
        });

        $('#setSecurityQuestionLink').click(function(e) {
            e.preventDefault();
            loadPageContent('/user/toSetSecurityQuestion');
        });

        function loadPageContent(url) {
            $.ajax({
                url: url,
                type: 'GET',
                success: function(data) {
                    $('#contentArea').html(data);
                },
                error: function() {
                    layer.msg('加载页面失败', {icon: 5});
                }
            });
        }

        // ⚠️页面加载完成后默认加载个人信息页
        loadPageContent('/user/toUserInfo');

        //头部事件
        util.event('lay-header-event', {
            menuLeft: function(othis){ // 左侧菜单事件
                layer.msg('展开左侧菜单的操作', {icon: 0});
            }
        });
    });

    // 获取图片路径
    WeChatSrc = document.getElementById("wechatImg").src;
    AlipaySrc = document.getElementById("alipayImg").src;

    // 捐赠弹窗
    function donation() {
        layer.tab({
            area: ['260px', '405px'],
            tab: [
                {
                    title: "微信",
                    content:
                        `<div style='overflow:hidden;background:#d2d0d0;'>
                            <img src="${WeChatSrc}" alt='作者微信收款码' style="width: 260px">
                         </div>`
                }, {
                    title: "支付宝",
                    content:
                        `<div style='overflow:hidden;background:#d2d0d0;'>
                            <img src="${AlipaySrc}" alt='作者支付宝收款码' style="width: 260px">
                         </div>`
                }
            ]
        })
    }
</script>
</body>
</html>